package com.hualan.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hualan.mapper.CourseCommentMapper;
import com.hualan.pojo.CourseComment;
import com.hualan.pojo.PageResult;
import com.hualan.service.CourseCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseCommentServiceImpl implements CourseCommentService {
    @Autowired
    private CourseCommentMapper courseCommentMapper;
    @Override
    public PageResult queryAllCourseComment(String username, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<CourseComment> courseCommentList = courseCommentMapper.queryAllCourseComment(username);
        Page<CourseComment> p=(Page<CourseComment>)courseCommentList;
        return new PageResult<>(p.getTotal(),p.getResult());
    }

    @Override
    public void deleteCourseComment(List<Integer> ids) {
        courseCommentMapper.deleteCourseComment(ids);
    }

    @Override
    public void saveCourseComment(CourseComment courseComment) {
        courseCommentMapper.saveCourseComment(courseComment);
    }

    @Override
    public void updateCourseComment(CourseComment courseComment) {
        courseCommentMapper.updateCourseComment(courseComment);
    }

    @Override
    public Object getCourseCommentById(Integer id) {
        return courseCommentMapper.getCourseCommentById(id);
    }
}
